﻿<!-- #include file="mymin.asp" -->
<card title="帖子管理"><p>
<%

dim p,id,rs,act,a,type_,typeName,typeLink
p=getN("p",1)
if p<1 then p=1
id=getN("id",1)
act=getD("act", "")
a=getN("a", 0)

Sub jingHua_(str, name)
	typeLink="<a href=""edit.asp?sid="&sid&"&amp;id="&id&"&amp;act=good&amp;"&str&""">["&name&"]</a><br/>"
End Sub

If act="" Then
	set rs=Server.CreateObject("ADODB.Recordset")
	rs.open"select t.title,t.type,t.pid,t.hit,t.savetime,c.name as class,u.name,u.id from (74hu_topic t left join 74hu_bbs c on t.classid=c.classid) left join 74hu_user u on t.userid=u.id where t.id="&id,myconn,1,1
	If Not rs.eof	Then
		type_=rs("type")
		Select Case type_
			Case 0
				typeName = "普通贴"
				jingHua_ "a=1", "设为精华"
			Case 1
				typeName = "精华贴"
				jingHua_ "a=0", "取消精华"
			Case 2
				typeName = "文件贴"
				jingHua_ "a=12", "设为精华"
			Case 12
				typeName = "精华文件贴"
				jingHua_ "a=2", "取消精华"
			Case 3
				typeName = "图片贴"
				jingHua_ "a=13", "设为精华"
			Case 13
				typeName = "精华图片贴"
				jingHua_ "a=3", "取消精华"
		End Select
		w "标题:"&nowml(rs("title"))&"<br/>"&_
			"论坛:"&nowml(rs("class"))&"<br/>"&_
			"作者:<a href=""detail.asp?id="&rs("id")&"&amp;sid="&sid&""">"&nowml(rs("name"))&"</a><br/>"&_
			"类型:"&typeName&"<br/>"&_
			"时间:"&rs("savetime")&"<br/>"&_
			"人气:"&rs("hit")&"<br/>"&_
			"<a href=""post.asp?sid="&sid&"&amp;id="&id&""">[预览帖子]</a><br/>"&_
			"<a href=""editpost.asp?sid="&sid&"&amp;id="&id&""">[帖子编辑]</a><br/>"&_
			"<a href=""movepost.asp?sid="&sid&"&amp;id="&id&""">[移动帖子]</a><br/>"&_
			"<a href=""edit.asp?sid="&sid&"&amp;id="&id&"&amp;act=del"">[删除帖子]</a><br/>"&_
			"----------<br/>"
		If rs("pid")=1 Then
			w "<a href=""edit.asp?sid="&sid&"&amp;id="&id&"&amp;act=top&amp;a=1"">[取消置顶]</a><br/>"
		Else
			w "<a href=""edit.asp?sid="&sid&"&amp;id="&id&"&amp;act=top"">[设为置顶]</a><br/>"
		End If
		w typeLink
	Else
		w "没有这个帖子！<br/>"
	end if
	rs.close
	set rs=nothing
elseif act="top" Then
	If a=1 Then'取消置顶
		myconn.execute("update 74hu_topic set pid=0 where id="&id)
		w "帖子成功取消置顶!"
	Else
		myconn.execute("update 74hu_topic set pid=1 where id="&id)
		w "帖子成功置顶!"
	End If
	w "<br/><a href=""edit.asp?sid="&sid&"&amp;id="&id&""">返回帖子</a><br/>"
elseif act="good" Then
	myconn.execute("update 74hu_topic set type="&a&",edittime='"&time_now&"' where id="&id)
	w "帖子设置成功!<br/><a href=""edit.asp?sid="&sid&"&amp;id="&id&""">返回帖子</a><br/>"
elseif act="del" Then
	If a=1 Then
		Set rs=Server.CreateObject("ADODB.Recordset")
		rs.open "select * from 74hu_topic where id="&id,myconn,1,3
		If Not rs.eof Then
			Dim usrid
			usrid=rs("userid")
			rs.delete
			rs.close
			Set rs=Nothing
			Server.ScriptTimeOut=999999
			myconn.execute("update 74hu_user set topic=topic-1 where id="&usrid)
			myconn.Execute("delete from 74hu_reply where postid="&id)'删除帖子要删除其中的回复
		End If
		w "删除成功!<br/>"
	Else
		w "删除之后无法恢复,确定删除?<br/><a href=""edit.asp?sid="&sid&"&amp;id="&id&"&amp;act=del&amp;a=1"">确定删除</a>"&_
			"<br/><a href=""edit.asp?sid="&sid&"&amp;id="&id&""">返回帖子</a><br/>"
	End If
Else
	w "操作失败!<br/>"
End If

w "----------<br/><a href=""posts.asp?sid="&sid&"&amp;"">[全部帖子]</a>"

call bbsLast
%>